package face.pay.common.order.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import face.pay.common.order.IOrderService;
import face.pay.dao.OrderInfoDao;
import face.pay.entity.OrderInfo;
import face.pay.entity.UserInfo;
import face.pay.util.page.PageData;
import face.pay.util.page.PageParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @Auther: zkj
 * @Date: 2019/8/1 12:00
 * @Description:
 */
@Service
public class OrderServiceImpl implements IOrderService {


    @Autowired
    private OrderInfoDao orderInfoDao;

    /**
     * 查询当前(商家用户订单)
     *
     * @param loginUser
     * @param params
     * @param pageParam
     * @return
     */
    @Override
    public PageData queryData(UserInfo loginUser, Map<String, Object> params, PageParam pageParam,
                              String startTime,String type,String payType,Integer storeId, Integer status) {

        PageHelper.startPage(pageParam.getPageNo(), pageParam.getPageSize());
        params.put("userId", loginUser.getId());
        params.put("startTime", startTime);
        params.put("type", type);
        params.put("payType", payType);
        params.put("storeId",storeId);
        params.put("status",status);

        List<OrderInfo> orderInfos = this.orderInfoDao.queryList(params);

        PageInfo<OrderInfo> pageInfo = new PageInfo<OrderInfo>(orderInfos);

        PageData<OrderInfo> pageData = new PageData<OrderInfo>(pageInfo.getTotal(), orderInfos);

        return pageData;
    }

}
